home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 567 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: unixg.ubc.ca!news
  2. From: csmecher@unixg.ubc.ca (Alec or Graeme Smecher)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help with screen blit function please!
  5. Date: Fri, 05 Jan 1996 02:40:01 GMT
  6. Organization: The University of British Columbia
  7. Message-ID: <4ci2qu$ntc@nntp.ucs.ubc.ca>
  8. Reply-To: csmecher@unixg.ubc.ca
  9. NNTP-Posting-Host: port10.annex2.net.ubc.ca
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Could somebody please tell me what is wrong with this screen blitter?
  13. I'll set the stage: This function is supposed to move 64,000 bytes
  14. from the address of "vscreen", into the VGA's screen segment
  15. (0xa000:0). When I run this program, I get a hang in dos, and a
  16. general protection fault in windows.
  17.  
  18. The example_vscreen is being allocated sucessfully and freed
  19. successfully after completion. Even if it wasn't being allocated
  20. properly, it wouldn't matter because it is being read from, not
  21. written to.
  22.  
  23. void *example_vscreen = malloc (64000);
  24.  
  25. void blit(void *vscreen) {
  26.     asm {
  27.         pusha
  28.         cld
  29.  
  30.         mov ax,0xa000 // es=0xa000
  31.         mov es,ax
  32.  
  33.         xor ax,ax // di=0
  34.         mov di,ax
  35.         //       ES:DI is now 0xa000:0
  36.  
  37.         mov ax,SEG vscreen
  38.         mov ds,ax
  39.                             // ds:si = segment and offset of vscreen
  40.         mov ax,OFFSET vscreen
  41.         mov si,ax
  42.  
  43.         mov cx,32000 // Loop 32000 times
  44.         rep movsw    // Do it
  45.  
  46.         popa
  47.         };
  48.     }
  49.  
  50. I'm relatively new to assembler, but pretty experienced in DOS C++
  51. coding (borland C++). Could somebody please tell me what is wrong with
  52. this code?
  53.  
  54. All answers appreciated!!
  55.  
  56. Thanks in advance,
  57. Alec Smecher (UBC, British Columbia, Canada)
  58. csmecher@unixg.ubc.ca
  59.  
  60.